package com.example.a2205douyin.util.aspectj;

import android.content.Intent;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.example.a2205douyin.MainActivity;
import com.example.a2205douyin.MyApp;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 切面
 */
@Aspect
public class AspectCheckLogin {
    @Pointcut("execution(@com.example.a2205douyin.util.aspectj.CheckLogin * *(..))")
    public void login(){}

    @Around("login()")
    public void aroundLogin(ProceedingJoinPoint point) throws Throwable {
        if(SPUtils.getInstance().getString("token").isEmpty()){
            //ToastUtils.showLong("还没有登录，去登录");
            MyApp.getContext().startActivity(new Intent(MyApp.getContext(), MainActivity.class));
        }else{
            //如果登录了，该点赞点赞，该关注关注
            point.proceed();
        }
    }
}
